package com.lc.rongzecaifu.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.lc.rongzecaifu.MyApplication;
import com.lc.rongzecaifu.rongzecaifu.R;
import com.lc.rongzecaifu.view.GuideView;
import com.zcx.helper.bound.BoundView;
import com.zcx.helper.pager.Guide;

import java.util.List;

public class GuideActivity extends BaseActivity {

    private List<View> mListViews;
    private ViewPager vp01;
    private boolean isLastPage = false;
    private boolean isDragPage = false;
    private boolean canJumpPage = true;
  /*  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);

        this.vp01 = (ViewPager) findViewById(R.id.vp_01);

        mListViews = new ArrayList<>();

        mListViews.add(BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) LayoutInflater.from(this)
                .inflate(R.layout.item_guide_one, null))));

        mListViews.add(BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) LayoutInflater.from(this)
                .inflate(R.layout.item_guide_two, null))));

        mListViews.add(BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) LayoutInflater.from(this)
                .inflate(R.layout.item_guide_three, null))));

        final GuidePagerAdapter guidePagerAdapter = new GuidePagerAdapter(GuideActivity.this, mListViews);

        vp01.setAdapter(guidePagerAdapter);

        vp01.setCurrentItem(0);
        vp01.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                Log.e("123","onPageScrolled");
              if (position==2){
                  //startActivity(new Intent(GuideActivity.this,MainActivity.class));
                  new Handler().postDelayed(new Runnable(){
                      public void run() {
                          //execute the task
                          startActivity(new Intent(GuideActivity.this,MainActivity.class));
                          finish();
                      }
                  }, 500000);

              }
            }

            @Override
            public void onPageSelected(int position) {
                Log.e("456","onPageSelected:"+position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {
                Log.e("789","onPageScrollStateChanged:"+state);
            }
        });*/

    @BoundView(R.id.guide_guide_view)
    private GuideView guideView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_guide_1);

        guideView.addLayoutId(R.layout.item_guide_one, R.layout.item_guide_two, R.layout.item_guide_three);

        guideView.setOnEndListener(new Guide.OnEndListener() {

            @Override
            public void onEnd() {

                //finish();

                MyApplication.myPreferences.saveIsGuide(true);
                startActivity(new Intent(GuideActivity.this, MainActivity.class));
                finish();
                //  finish();
            }

        });

    }
}
